package com.yh.controller;

import com.yh.util.BaseAction;
import lombok.Data;

import java.io.IOException;
import java.io.PrintWriter;

@Data
public class UserAction extends BaseAction {

    private  String username;
    private  String password;

    public String login() {
        if("admin".equals(username)&&"admin".equals(password)||"lisi".equals(username)&&"123".equals(password)){
            getMapSession().put("name",username);
            return SUCCESS;
        }else {
            getRequest().setAttribute("msg","用户名或密码错误,请重新<a href='login.jsp'>登录</a>");
            return "error";
        }
    }
    public String addUser() throws IOException {
        PrintWriter out = getResponse().getWriter();
        out.print("<h2>正在执行添加用户</h2>");
        return null;
    }
}
